<template>
  <div>
    <el-table :data="showdate" style="width:100%">
      <el-table-column prop="id" label="序号"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="age" label="年龄"></el-table-column>
      <el-table-column label="性别">
        <template slot-scope="props">
          <span>{{props.row.sex | sex}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="email" label="邮箱"></el-table-column>
      <el-table-column prop="phone" label="手机号码"></el-table-column>
    </el-table>
    <div class="fy">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="newdate.length"
        @current-change="change"
        :page-size="11"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      newdate: [],
      showdate: []
    };
  },
  created() {
    this.$http.get("/api/user").then(res => {
      this.newdate = res.data.data;
      this.showdate = this.newdate.slice(0, 11);  //开始的时候展示0-11个  不加开始时没有数据
    });
  },
  methods: {
    change(value) {
      let min = (value - 1) * 11;
      let max = value * 11;
      this.showdate = this.newdate.slice(min, max);
    }
  }
};
</script>

<style>
.fy{ 
    text-align: center;
    margin: 30px;
}
</style>